From d41eff9eccf66644c4c60f53cb516bf079937a28 Mon Sep 17 00:00:00 2001 From: aman333nolawz Date: Mon, 2 Mar 2026 21:49:13 +0530 Subject: Using astro-erudite for static site generation --- src/pages/authors/[...id].astro | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/pages/authors/[...id].astro (limited to 'src/pages/authors/[...id].astro') diff --git a/src/pages/authors/[...id].astro b/src/pages/authors/[...id].astro new file mode 100644 index 0000000..d71fcf8 --- /dev/null +++ b/src/pages/authors/[...id].astro @@ -0,0 +1,58 @@ +--- +import AuthorCard from '@/components/AuthorCard.astro' +import BlogCard from '@/components/BlogCard.astro' +import Breadcrumbs from '@/components/Breadcrumbs.astro' +import PageHead from '@/components/PageHead.astro' +import Layout from '@/layouts/Layout.astro' +import { getAllAuthors, getPostsByAuthor } from '@/lib/data-utils' + +export async function getStaticPaths() { + const authors = await getAllAuthors() + return authors.map((author) => ({ + params: { id: author.id }, + props: { author }, + })) +} + +const { author } = Astro.props +const authorPosts = await getPostsByAuthor(author.id) +--- + + + + + +
+ +
+
+

Posts by {author.data.name}

+ { + authorPosts.length > 0 ? ( +
    + {authorPosts + .filter((post) => !post.data.draft) + .map((post) => ( +
  • + +
  • + ))} +
+ ) : ( +

+ No posts available from this author. +

+ ) + } +
+
-- cgit v1.2.3